
module Backend = Backend_Java

let _ =
  let max_args = int_of_string (Sys.argv.(1)) in
  let object_class = AstO.Class("Object", "Object", [], []) in
  let value_class = AstO.Class("Value", "Object", [], []) in
  let st = List.map (fun (AstO.Class(name ,_ ,_ ,_ ) as cls) -> (Type.Class name,cls)) 
    ([object_class; value_class] @ GenSupportClasses.make_all_classes max_args)
  in
    List.iter (Backend.generate_class st) (GenSupportClasses.make_all_classes max_args)
(*

let x = 3 in
let y = 6 in
let f a b = a + b in
(f x y);;

#load "listAux.cmo";;
#load "const.cmo";;
#load "ast.cmo";;
#load "astO.cmo";;
#load "lexer.cmo";;
#load "parser.cmo";;
#load "compiler.cmo";;
#load "genSupportClasses.cmo";;
#load "type.cmo";;
#load "backend_Java.cmo";;

let lexbuf = Lexing.from_channel stdin;;
let expr = Parser.main Lexer.token lexbuf ;;

(tail [1;2;3]);;

let (classes, expr') = Compiler.compile expr ;;

let prelude = AstO.Class( "Prelude","Object",[],
			    [AstO.Method (AstO.Static,"Int","addInt",[("Int","m");("Int","n")],
					  None);
			     AstO.Method (AstO.Static,"Int","subInt",[("Int","m");("Int","n")],
					  None);
		
   let (AstO.Class (name, base, fields, methods) as cls) = List.hd classes;;
  let AstO.Method (qual, typ, method_name, args, expr_opt) = List.hd methods;;
  let cls = "C_0";;
  let env = (if qual = AstO.Static then [] else [("this",Type.Class cls)]) @
              (List.map (fun (typ,var) -> (var,Type.Class typ)) args);;
  let expr = (fun (Some e) -> e) expr_opt;;

*)
  
